$(function(){
	// 字符验证       
	jQuery.validator.addMethod("stringCheck", function(value, element) {       
		return this.optional(element) || /^\w+$/.test(value);       
	}, "只能包括英文字母、数字和下划线");
	// 手机号码验证       
	jQuery.validator.addMethod("isMobile", function(value, element) {       
		var length = value.length;   
		var mobile = /^(13[0-9]|15[0-9]|18[0-9]|14[0-9])\d{8}$/;   
		return this.optional(element) || (length == 11 && mobile.test(value)); 
	}, "请正确填写您的手机号码");
	$("#form1").validate({
		rules: {
			
		},
		messages: {
			old_password:{
				required:"请输入原始密码",
				minlength:"用户名不能少于4个字符",
				maxlength:"用户名不能超过20个字符"
			},
			new_password:{
				required:"请输入新的密码",
				minlength:"用户名不能少于4个字符",
				maxlength:"用户名不能超过20个字符"
			},
			new_password_confirm:{
				required:"请再输入一次新的密码",
				minlength:"用户名不能少于4个字符",
				maxlength:"用户名不能超过20个字符",
				equalTo: "两次输入的密码要一致"
			}
		},
		highlight: function(element) {
			$(element).removeClass('success').addClass('error');
			//当某个input验证成功后再失败的话，添加的ok类依然存在
			$(element).parent().next().children('label.ok').removeClass('ok');
		},
		// the errorPlacement has to take the layout into account
		errorPlacement: function(error, element) {
			error.appendTo(element.parent().next());
		},
		// specifying a submitHandler prevents the default submit, good for the demo
		submitHandler: function(form) {
			alert("Data submitted!");
			//form.submit();
		},
		// set new class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("ok");
		}
	});
});